{% extends "master.html" %}
{% from "_formhelpers.html" import render_field_in_row %}

{% block title %}Host Category{% endblock %}
{%block tag %}home{% endblock %}

{% block header %}
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css"
  rel="stylesheet">
{% endblock %}

{% block content %}
<h2>Host category</h2>

<p>
  Back to <a href="{{ url_for('site_view', site_id=host.site_id) }}">
    {{ host.site.name }}</a> / <a href="{{ url_for('host_view', host_id=host.id) }}">
    {{ host.name }}</a>
</p>

<p>
   Hosts carry categories of software. Example Fedora categories include
   Fedora and Fedora Archive.
</p>

{% if is_admin %}
<form action="{{ url_for('host_category', host_id=host.id,
                 hc_id=hostcategory.id) }}" method="POST">
  <table>
    {{ render_field_in_row(form.always_up2date) }}
  </table>
  <p class="buttons indent">
    <input type="submit" class="submit positive button" value="Update">
    {{ form.csrf_token }}
  </p>
</form>
{% endif %}

<h3>URLs serving this content</h3>

<p>
  The same content may be served by multiple means: http, https, and rsync
  are common examples. Content may also be served via a 'private' URL only
  visible to other mirror admins. Such private URLs usually include a
  nonstandard rsync port, and/or a username and password. Admins from Mirror
  Sites on your SiteToSite list can see these private URLs.
</p>

<a class="icon icon-plus-sign blue"
  href="{{ url_for('host_category_url_new', host_id=host.id,
           hc_id=hostcategory.id) }}"> [add]</a>

{% if hostcategory.urls %}
<ul>
  {% for urls in hostcategory.urls %}
  <li>
    <form class="icon" method="POST"
        action="{{ url_for('host_category_url_delete', host_id=host.id,
                   hc_id=hostcategory.id, host_category_url_id=urls.id) }}">
      {{ urls.url }}
      {{ form.csrf_token }}
        <button
          onclick="return confirm('You sure you want to delete this url?');"
          title="Delete url">
          <span class="icon icon-trash blue"></span>
        </button>
        {%- if urls.private -%}
          (Private URL - This URL will not show up in the mirrorlist/metalink)
        {%- endif -%}
    </form>
  </li>
  {% endfor %}
</ul>
{% endif %}

{% if hostcategory.directories %}
<h3>Up-to-Date Directories this host carries</h3>
<ul>
{% for dir in hostcategory.directories %}
  {% if dir.up2date %}
    <li>{{ dir.path }}</li>
  {% endif %}
{% endfor %}
</ul>
{% endif %}

{% endblock %}
